package com.apexsoft.front.common.utils.session;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

/**
 * session对象
 * @author dinglei
 *
 */
public class SessionObject implements Serializable {
	
	private static final long serialVersionUID = -9212292940305079065L;
	
	private Map<String,Object> session = null;
	
	public SessionObject(){
		session = new HashMap<String,Object>();
	}
	
	public void setAttribute(String key,Object obj){
		if(session!=null){
			session.put(key, obj);
		}
	}
	
	public Object getAttribute(String key){
		if(session!=null){
			return session.get(key);
		}
		return null;
	}
	
	public void removeAttribute(String key){
		if(session!=null){
			session.remove(key);
		}
	}
	
	public String toString(){
		StringBuffer str = new StringBuffer();
		for(Iterator<String> it = session.keySet().iterator();it.hasNext();)
		{
			String key = it.next();
			Object value = session.get(key);
			str.append(key);
			str.append(":		");
			str.append(value.toString());
			str.append("\n");
		}
		System.out.println(str.toString());
		return str.toString();
	}

}
